package com.sw.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.pagehelper.Page;
import com.sw.pojo.BlockInfo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;

@Repository
public interface BlockDao extends BaseMapper<BlockInfo> {
    @Select("SELECT ifNull(MAX(number),0) FROM block")
    BigInteger selectMaxNum();


	@Select("<script>select * from block <if test=\"queryString!=null and queryString!=''\">where number=#{queryString} or hash=#{queryString}</if></script>")
    Page<BlockInfo> selectByCondition(@Param("queryString")String queryString);

	

//    @Insert("INSERT INTO block('number','hash','parentHash','miner'," +
//            "'difficulty','size','gasLimit','gasUsed','timestamp') VALUES(#{number}," +
//            "#{hash},#{parentHash},#{miner},#{difficulty},#{size},#{gasLimit},#{gasUsed},#{timestamp})")
//    void saveBlockInfo(BlockInfo blockInfo);
}
